<template>
  <div id="problems">
    <search-bar @problems="searchProblems"
                @loading="getLoading"></search-bar>
    <div class="body-container"
         v-loading="loading">
      <div class="card-list">
        <Card v-for="(problem) in problems"
              :key="problem.problem_id"
              :problem="problem"></Card>
      </div>
    </div>
  </div>
</template>

<script>
import SearchBar from './components/SearchBar'
import Card from './components/Card'

export default {
  name: 'problems',
  data () {
    return {
      loading: true,
      problems: []
    }
  },
  components: {
    SearchBar,
    Card
  },
  methods: {
    searchProblems (val) {
      this.problems = val
    },
    getLoading (val) {
      this.loading = val
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '~styles/varibles.styl'

.search-bar
  width 40%
  margin 80px auto
  margin-top 120px
.body-container
  position relative
  width 60%
  min-height 500px
  margin 0 auto
  .card-list
    display grid
    justify-items center
    grid-template-columns repeat(auto-fill, minmax(300px, 1fr))
    grid-gap 10px
</style>
